package com.google.code.jcooky.chat.client.service;

import java.io.IOException;
import java.net.URL;
import java.util.List;

import com.google.code.jcooky.chat.commons.jrc.Message;
import com.google.code.jcooky.chat.commons.jrc.SystemInfo;
import com.google.code.jcooky.rpc.protocol.JSONProtocol;
import com.google.code.jcooky.rpc.transport.JSONTransport;

public class ChatService implements com.google.code.jcooky.chat.commons.jrc.ChatService.Iface {

	private com.google.code.jcooky.chat.commons.jrc.ChatService.Iface client;

	public ChatService(URL url) throws IOException {
		client = new  com.google.code.jcooky.chat.commons.jrc.ChatService.Client(new JSONProtocol(new JSONTransport(url)));
	}

	@Override
	public Boolean add(String id) {
		synchronized (client) {
			return client.add(id);
		}
	}

	@Override
	public void remove(String id) {
		synchronized (client) {
			client.remove(id);
		}
	}

	@Override
	public List<String> getEnteredList(String id) {
		synchronized (client) {
			return client.getEnteredList(id);
		}
	}

	@Override
	public List<String> getEnterUser(String id) {
		synchronized (client) {
			return client.getEnterUser(id);
		}
	}

	@Override
	public List<String> getClosedUser(String id) {
		synchronized (client) {
			return client.getClosedUser(id);
		}
	}

	@Override
	public List<Message> getMessage(String id) {
		synchronized (client) {
			return client.getMessage(id);
		}
	}

	@Override
	public void addMessage(String id, String msg) {
		synchronized (client) {
			client.addMessage(id, msg);
		}
	}

	@Override
	public List<SystemInfo> getSystemInfo(String id) {
		synchronized (client) {
			return client.getSystemInfo(id);
		}
	}

}
